# 文本识别
# coding: utf-8

import json
from paddleocr import TextRecognition
model = TextRecognition(model_name="PP-OCRv5_server_rec")
output = model.predict(input="general_ocr_rec_001.png", batch_size=1)
for res in output:
    # res.print()
    res.save_to_img(save_path="./output/")
    res.save_to_json(save_path="./output/res.json")
    # json 读取
    with open("./output/res.json", "r", encoding="utf-8") as f:
        data = json.load(f)
        print(data["rec_text"])
        print(data["rec_score"])
